package dao.impl;

import dao.CourseDao;
import pojo.Course;

import java.util.List;

public class CourseDaoImpl extends BaseDao implements CourseDao {
    @Override
    public int addCourse(Course course) {
        String sql="insert into course (cno,cname,score,grade) values (?,?,?,?)";
        return update(sql,course.getCno(),course.getCname(),course.getScore(),course.getGrade());
    }

    @Override
    public int deleteCoursebyCno(String cno) {
        String sql = "delete from course where cno=?";
        return update(sql,cno);
    }

    @Override
    public int upDateCourse(Course course) {
        String sql="update course set cname=? , score=?, grade=? where cno=?";
        return update(sql,course.getCname(),course.getScore(),course.getGrade(),course.getCno());
    }

    @Override
    public Course queryCourseByCno(String cno) {
        String sql = "select cno,cname,score,grade from course where cno=?";
        return queryForOne(Course.class,sql,cno);
    }

    @Override
    public List<Course> queryCourse() {
        String sql="select cno,cname,score,grade from course";
        return queryForList(Course.class,sql);
    }
}
